package com.yaofeng.mybatis.exception;

import com.yaofeng.mybatis.common.ErrorCodeEnum;
import com.yaofeng.mybatis.common.ResponseInfo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * 自定义全局业务异常
 * Created by yaofeng on 2019/8/14.
 */

@Getter
@Setter
public class BusinessException extends RuntimeException {

    private Integer errCode;
    private String errMsg;

    public BusinessException(String errMsg) {
        super(errMsg);
        this.errCode = ResponseInfo.FAIL_CODE;
        this.errMsg = errMsg;
    }

    public BusinessException(){
        super();
    }

    public BusinessException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getErrMsg());
        this.errCode = errorCodeEnum.getErrCode();
        this.errMsg = errorCodeEnum.getErrMsg();
    }




}
